microbit = codesters.Microbit()
microbit.show_string("hello")
data = microbit.get_temp()
microbit.show_number(data)
data_list = []
time_list = []
my_display = codesters.ScatterPlot(time_list, data_list)
time = 0
def interval():
data = microbit.get_temp()
data_list.append(data)
global time
time_list.append(time)
my_display.update(time_list, data_list)
stage.event_interval(interval, 2)
t = codesters.Teacher()
add_var = t.find_text('+=')
try:
tval1 = add_var[0][1].replace(' ', '')
tval2 = t.get_indent_at_line(add_var[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success('time+=1' in tval1 and tval2 == 4, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add an Add Value command inside your interval event?")
t1.add_failure('time+=' not in tval1, "Did you change the variable in front of += to time?")
t1.add_failure('+=1' not in tval1, "Oops! Make sure the number we add to time is 1!")
t1.add_failure(tval2 < 4, "Make sure your Add Value command is indented INSIDE your interval event!")
t1.add_failure(tval2 > 4, "Make sure your Add Value command is indented only 4 spaces!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)